﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.hud.components {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import org.aswing.*;
    import Classes.util.*;
    import Display.*;
    import Display.aswingui.*;

    public class HUDGetCurrencyComponent extends HUDComponent {

        override protected function buildComponent():void{
            var _local2:JButton;
            var _local1:Sprite = new Sprite();
            this.addChild(_local1);
            if (Global.flashSaleManager.isFlashSaleAvailable){
                _local2 = new CustomButton(ZLoc.t("Main", "AddCoinsCash_Sale"), null, "AddCoinsSaleButtonUI");
                _local2.addActionListener(this.onGetCurrency, 0, true);
            } else {
                if (Global.freeGiftSaleManager.canShowSale(false) === true){
                    _local2 = new CustomButton(ZLoc.t("Main", "FreeGift_Sale"), null, "FreeGiftSaleButtonUI");
                    _local2.addActionListener(this.onFreeGiftOfferClick, 0, true);
                } else {
                    _local2 = new CustomButton(ZLoc.t("Main", "AddCoinsCash"), null, "AddCoinsButtonUI");
                    _local2.addActionListener(this.onGetCurrency, 0, true);
                };
            };
            var _local3:JWindow = new JWindow(_local1);
            var _local4:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.RIGHT);
            _local4.append(_local2);
            _local3.setContentPane(_local4);
            ASwingHelper.prepare(_local3);
            _local3.show();
        }
        override public function refresh(_arg1:Boolean):void{
            this.buildComponent();
        }
        override protected function attachToolTip():void{
            m_toolTip = new ToolTip(function ():String{
                return (ZLoc.t("Main", "GetCurrency_ToolTip"));
            });
            m_toolTip.attachToolTip(this);
            m_toolTip.hideCursor = true;
        }
        private function onGetCurrency(_arg1:Event):void{
            StatsManager.count("get_coins", "click_ok");
            FrameManager.showTray("money.php?ref=coinsDialog");
        }
        private function onFreeGiftOfferClick(_arg1:Event):void{
            UI.displayPopup(Global.freeGiftSaleManager.getStartupDialog());
        }

    }
}//package Display.hud.components 
